home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
util
/
gnu
/
diff_2_3.lha
/
diff-2.3
/
amiga-diff.diffs
< prev
next >
Wrap
Text File
|
1993-05-26
|
27KB
|
1,078 lines
diff -cr ram:diff-2.3/alloca.c dh1:diff-2.3/alloca.c
*** ram:diff-2.3/alloca.c Wed May 12 01:23:34 1993
--- dh1:diff-2.3/alloca.c Wed May 26 20:18:59 1993
***************
*** 74,79 ****
--- 74,83 ----
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
+ #ifdef AMIGA
+ #define STACK_DIRECTION -1
+ #endif /* AMIGA */
+
#ifndef STACK_DIRECTION
#define STACK_DIRECTION 0 /* Direction unknown. */
#endif
diff -cr ram:diff-2.3/cmp.c dh1:diff-2.3/cmp.c
*** ram:diff-2.3/cmp.c Wed Jul 08 21:58:06 1992
--- dh1:diff-2.3/cmp.c Wed May 26 20:19:00 1993
***************
*** 28,33 ****
--- 28,36 ----
int cmp ();
void printc ();
void error ();
+ #ifdef AMIGA
+ void fake_stat_result ();
+ #endif /* AMIGA */
/* Name under which this program was invoked. */
char *program_name;
***************
*** 166,175 ****
--- 169,191 ----
usage ("at least one filename should be specified");
}
+ #ifndef AMIGA
if (fstat (file1_desc, &stat_buf1) < 0)
error (2, errno, "%s", file1);
if (fstat (file2_desc, &stat_buf2) < 0)
error (2, errno, "%s", file2);
+ #else /* AMIGA */
+ if (file1_desc != 0)
+ if (fstat (file1_desc, &stat_buf1) < 0)
+ error (2, errno, "%s", file1);
+ else
+ fake_stat_result (&stat_buf1);
+ if (file2_desc != 0)
+ if (fstat (file2_desc, &stat_buf2) < 0)
+ error (2, errno, "%s", file2);
+ else
+ fake_stat_result (&stat_buf2);
+ #endif /* AMIGA */
/* If both the input descriptors are associated with plain files,
we can make the job simpler in some cases. */
***************
*** 185,190 ****
--- 201,207 ----
/* If output is redirected to "/dev/null", we may assume `-s'. */
+ #ifndef AMIGA
if (comparison_type != type_status)
{
struct stat sb;
***************
*** 200,205 ****
--- 217,223 ----
comparison_type = type_status;
}
}
+ #endif /* AMIGA */
/* If only a return code is needed, conclude that
the files differ if they have different sizes. */
***************
*** 510,512 ****
--- 528,548 ----
while (--width > 0)
putc (' ', fs);
}
+
+ #ifdef AMIGA
+ void fake_stat_result (sbuf)
+ struct stat *sbuf;
+ {
+ time_t cur_time;
+
+ time (&cur_time);
+ sbuf->st_dev = 0;
+ sbuf->st_ino = 0;
+ sbuf->st_mode = S_IREAD;
+ sbuf->st_nlink = 1;
+ sbuf->st_uid = 0;
+ sbuf->st_gid = 0;
+ sbuf->st_size = 0;
+ sbuf->st_ctime = sbuf->st_atime = sbuf->st_mtime = cur_time;
+ }
+ #endif /* AMIGA */
diff -cr ram:diff-2.3/diff.c dh1:diff-2.3/diff.c
*** ram:diff-2.3/diff.c Fri Apr 23 19:18:44 1993
--- dh1:diff-2.3/diff.c Wed May 26 20:19:40 1993
***************
*** 41,46 ****
--- 41,49 ----
static void add_regexp();
static void specify_style ();
static void usage ();
+ #ifdef AMIGA
+ static int fake_stat_result ();
+ #endif /* AMIGA */
/* Nonzero for -r: if comparing two directories,
compare their common subdirectories recursively. */
***************
*** 727,734 ****
--- 730,760 ----
if (name1 == 0)
name1 = name0;
+ #ifndef AMIGA
inf[0].name = dir0 == 0 ? name0 : concat (dir0, "/", name0);
inf[1].name = dir1 == 0 ? name1 : concat (dir1, "/", name1);
+ #else /* AMIGA */
+ {
+ int len;
+ if (dir0 != 0) len = strlen (dir0);
+ if (dir0 == 0 || len == 0)
+ inf[0].name = name0;
+ else if (dir0[len-1] == ':')
+ inf[0].name = concat (dir0, "", name0);
+ else
+ inf[0].name = concat (dir0, "/", name0);
+ }
+ {
+ int len;
+ if (dir1 != 0) len = strlen (dir1);
+ if (dir1 == 0 || len == 0)
+ inf[1].name = name1;
+ else if (dir1[len-1] == ':')
+ inf[1].name = concat (dir1, "", name1);
+ else
+ inf[1].name = concat (dir1, "/", name1);
+ }
+ #endif /* AMIGA */
/* Stat the files. Record whether they are directories. */
***************
*** 745,751 ****
--- 771,781 ----
{
inf[i].desc = 0;
inf[i].name = "Standard Input";
+ #ifndef AMIGA
stat_result = fstat (0, &inf[i].stat);
+ #else /* AMIGA */
+ stat_result = fake_stat_result (&inf[i].stat);
+ #endif /* AMIGA */
}
else
stat_result = stat (inf[i].name, &inf[i].stat);
***************
*** 770,780 ****
--- 800,828 ----
/* If one is a directory, and it was specified in the command line,
use the file in that dir with the other file's basename. */
+ #ifndef AMIGA
int fnm_arg = inf[0].dir_p;
int dir_arg = 1 - fnm_arg;
char *p = rindex (inf[fnm_arg].name, '/');
char *filename = inf[dir_arg].name
= concat (inf[dir_arg].name, "/", (p ? p+1 : inf[fnm_arg].name));
+ #else /* AMIGA */
+ int fnm_arg, dir_arg;
+ char *p1, *p2, *p;
+ char *filename;
+
+ fnm_arg = inf[0].dir_p;
+ dir_arg = 1 - fnm_arg;
+ p1 = rindex (inf[fnm_arg].name, '/');
+ p2 = rindex (inf[fnm_arg].name, ':');
+ p = max (p1, p2);
+ if (*(inf[dir_arg].name + strlen (inf[dir_arg].name) - 1) == ':')
+ filename = inf[dir_arg].name
+ = concat (inf[dir_arg].name, "", (p ? p+1 : inf[fnm_arg].name));
+ else
+ filename = inf[dir_arg].name
+ = concat (inf[dir_arg].name, "/", (p ? p+1 : inf[fnm_arg].name));
+ #endif /* !AMIGA */
if (inf[fnm_arg].desc == 0)
fatal ("can't compare - to a directory");
***************
*** 918,927 ****
--- 966,1001 ----
else
fflush (stdout);
+ #ifndef AMIGA
if (dir0 != 0)
free (inf[0].name);
if (dir1 != 0)
free (inf[1].name);
+ #else /* AMIGA */
+ if (dir0 != 0 && strlen(dir0) != 0)
+ free (inf[0].name);
+ if (dir1 != 0 && strlen(dir1) != 0)
+ free (inf[1].name);
+ #endif /* !AMIGA */
return val;
}
+
+ #ifdef AMIGA
+ static int fake_stat_result (sbuf)
+ struct stat *sbuf;
+ {
+ time_t cur_time;
+
+ time (&cur_time);
+ sbuf->st_dev = 0;
+ sbuf->st_ino = 0;
+ sbuf->st_mode = S_IREAD;
+ sbuf->st_nlink = 1;
+ sbuf->st_uid = 0;
+ sbuf->st_gid = 0;
+ sbuf->st_size = 0;
+ sbuf->st_ctime = sbuf->st_atime = sbuf->st_mtime = cur_time;
+ return 0;
+ }
+ #endif /* AMIGA */
diff -cr ram:diff-2.3/diff3.c dh1:diff-2.3/diff3.c
*** ram:diff-2.3/diff3.c Fri Apr 23 19:18:44 1993
--- dh1:diff-2.3/diff3.c Wed May 26 20:52:39 1993
***************
*** 28,33 ****
--- 28,43 ----
#include "getopt.h"
#include "system.h"
+ #ifdef AMIGA
+ #include <signal.h>
+ #include <exec/types.h>
+ #include <dos/dostags.h>
+ #include <proto/dos.h>
+ #include <proto/exec.h>
+
+ extern struct DosLibrary *DOSBase;
+ #endif /* AMIGA */
+
/*
* Internal data structures and macros for the diff3 program; includes
* data structures for both diff3 diffs and normal diffs.
***************
*** 243,248 ****
--- 253,265 ----
char **file;
struct stat statb;
+ #ifdef AMIGA
+ if (DOSBase->dl_lib.lib_Version < 37) {
+ fputs ("Need Amiga OS 2.0 (V.37) to execute.\n", stderr);
+ exit (20);
+ }
+ #endif /* AMIGA */
+
incompat = 0;
argv0 = argv[0];
***************
*** 1100,1105 ****
--- 1117,1124 ----
char *filea, *fileb;
char **output_placement;
{
+ #ifndef AMIGA
+
char *argv[7];
char horizon_arg[256];
char **ap;
***************
*** 1146,1151 ****
--- 1165,1243 ----
perror_with_exit ("fork failed");
close (fds[1]); /* Prevent erroneous lack of EOF */
+
+ #else /* AMIGA */
+
+ static char diff_command_line[256];
+ char horizon_arg[100];
+ int fds[2];
+ char *diff_result;
+ int current_chunk_size;
+ int bytes;
+ int total;
+ void (*oldsigint)();
+ static long num_invocations = 0;
+ char pipe_name[20];
+ struct Task *Task;
+ struct TagItem STags[5];
+ BPTR StdOutDiff;
+
+ /* The user should not be able to break the program while the child
+ process is being executed, otherwise the child process will still
+ be writing to the pipe-device until it deadlocks because there is
+ no reader on the other side of the pipe. So prohibit breaking the
+ program until the pipe is closed. */
+ oldsigint = signal (SIGINT, SIG_IGN);
+
+ /* Construct command line. Enclose filenames in double quotes in
+ case the user specifies files with spaces in their names. */
+ strcpy (diff_command_line, diff_program);
+ if (always_text)
+ strcat (diff_command_line, " -a");
+ sprintf (horizon_arg, " --horizon-lines=%d", horizon_lines);
+ strcat (diff_command_line, horizon_arg);
+ strcat (diff_command_line, " --");
+ strcat (diff_command_line, " \"");
+ strcat (diff_command_line, filea);
+ strcat (diff_command_line, "\" \"");
+ strcat (diff_command_line, fileb);
+ strcat (diff_command_line, "\"");
+
+ /* Construct filename for the pipe to be used */
+ Task = FindTask (NULL);
+ num_invocations++;
+ sprintf (pipe_name, "PIPE:%08lX_%ld", Task, num_invocations);
+
+ /* Open pipe for child process */
+ StdOutDiff = Open (pipe_name, MODE_NEWFILE);
+ if (!StdOutDiff)
+ perror_with_exit ("pipe failed");
+
+ /* Child process runs asynchronously with pipe as stdout */
+ STags[0].ti_Tag = SYS_Input;
+ STags[0].ti_Data = NULL;
+ STags[1].ti_Tag = SYS_Output;
+ STags[1].ti_Data = StdOutDiff;
+ STags[2].ti_Tag = SYS_Asynch;
+ STags[2].ti_Data = TRUE;
+ STags[3].ti_Tag = SYS_UserShell;
+ STags[3].ti_Data = TRUE;
+ STags[4].ti_Tag = TAG_DONE;
+ /* Start child process */
+ if ((System (diff_command_line, STags)) != 0) {
+ Close (StdOutDiff);
+ perror_with_exit ("diff: not found");
+ }
+
+ /* Open pipe for this side of the communication */
+ fds[0] = open (pipe_name, O_RDONLY);
+ if (fds[0] < 0) {
+ Close (StdOutDiff);
+ perror_with_exit ("pipe failed");
+ }
+
+ #endif /* !AMIGA */
+
current_chunk_size = DIFF_CHUNK_SIZE;
diff_result = (char *) xmalloc (current_chunk_size);
total = 0;
***************
*** 1163,1168 ****
--- 1255,1261 ----
*output_placement = diff_result;
+ #ifndef AMIGA
do
if ((w = wait (&wstatus)) == -1)
perror_with_exit ("wait failed");
***************
*** 1170,1175 ****
--- 1263,1274 ----
if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
fatal ("subsidiary diff failed");
+ #else /* AMIGA */
+ /* Close pipe */
+ close (fds[0]);
+ /* Re-install break-handler */
+ signal (SIGINT, oldsigint);
+ #endif /* !AMIGA */
return diff_result + total;
}
diff -cr ram:diff-2.3/fnmatch.c dh1:diff-2.3/fnmatch.c
*** ram:diff-2.3/fnmatch.c Fri Apr 16 18:24:54 1993
--- dh1:diff-2.3/fnmatch.c Wed May 26 20:30:25 1993
***************
*** 20,26 ****
--- 20,30 ----
#endif
#include <errno.h>
+ #ifndef AMIGA
#include <fnmatch.h>
+ #else /* AMIGA */
+ #include "fnmatch.h"
+ #endif /* !AMIGA */
#include <ctype.h>
diff -cr ram:diff-2.3/getopt.c dh1:diff-2.3/getopt.c
*** ram:diff-2.3/getopt.c Fri May 07 21:29:58 1993
--- dh1:diff-2.3/getopt.c Wed May 26 20:20:26 1993
***************
*** 42,50 ****
--- 42,52 ----
#endif /* alloca.h */
#endif /* not __GNUC__ */
+ #ifndef AMIGA
#if !__STDC__ && !defined(const) && IN_GCC
#define const
#endif
+ #endif /* !AMIGA */
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
#ifndef _NO_PROTO
diff -cr ram:diff-2.3/getopt1.c dh1:diff-2.3/getopt1.c
*** ram:diff-2.3/getopt1.c Fri May 07 21:29:54 1993
--- dh1:diff-2.3/getopt1.c Wed May 26 20:20:27 1993
***************
*** 22,30 ****
--- 22,32 ----
#include "getopt.h"
+ #ifndef AMIGA
#if !__STDC__ && !defined(const) && IN_GCC
#define const
#endif
+ #endif /* !AMIGA */
#include <stdio.h>
diff -cr ram:diff-2.3/sdiff.c dh1:diff-2.3/sdiff.c
*** ram:diff-2.3/sdiff.c Thu Feb 11 09:39:42 1993
--- dh1:diff-2.3/sdiff.c Wed May 26 20:20:51 1993
***************
*** 25,30 ****
--- 25,39 ----
#include <signal.h>
#include "getopt.h"
+ #ifdef AMIGA
+ #include <exec/types.h>
+ #include <dos/dostags.h>
+ #include <proto/exec.h>
+ #include <proto/dos.h>
+
+ extern struct DosLibrary *DOSBase;
+ #endif /* AMIGA */
+
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
***************
*** 49,69 ****
--- 58,93 ----
static char *tmpname;
static int volatile tmpmade;
+ #ifndef AMIGA
static pid_t volatile diffpid;
+ #endif /* !AMIGA */
struct line_filter;
static void diffarg (); /* (char *); */
static void execdiff (); /* (int, char const *, char const *, char const *); */
+ #ifdef AMIGA
+ char *xmalloc ();
+ static void amiga_exit ();
+ static int amiga_break ();
+ static void construct_pipe_name ();
+ static void construct_command_line ();
+ static char command_line[512];
+ static FILE *diff_file = NULL;
+ static int user_quit = 0;
+ #endif /* AMIGA */
static int edit (); /* (struct line_filter *left, int lenl, struct
line_filter *right, int lenr, FILE *outfile); */
static int interact (); /* (struct line_filter *diff,
struct line_filter *left,
struct line_filter *right, FILE *outfile); */
+ #ifndef AMIGA
static void trapsigs (); /* (void); */
/* this lossage until the gnu libc conquers the universe */
#define TMPNAMSIZE 1024
#define PVT_tmpdir "/tmp"
static char *private_tempnam (); /* (const char *, const char *, int, int *); */
+ #endif /* !AMIGA */
+
static int diraccess ();
/* Options: */
***************
*** 108,120 ****
--- 132,185 ----
exit (2);
}
+ #ifdef AMIGA
+ static void
+ amiga_exit ()
+ {
+ char *buf;
+ size_t a;
+
+ if (tmpmade)
+ {
+ remove (tmpname);
+ tmpmade = 0;
+ }
+ if (diff_file)
+ {
+ /* Provide empty pipe! */
+ buf = xmalloc (SDIFF_BUFSIZE);
+ do
+ a = fread (buf, sizeof (char), SDIFF_BUFSIZE, diff_file);
+ while (a == SDIFF_BUFSIZE);
+ fclose (diff_file);
+ diff_file = NULL;
+ free (buf);
+ }
+ }
+
+ static int
+ amiga_break ()
+ {
+ amiga_exit ();
+ return 20;
+ }
+ #endif /* AMIGA */
+
static void
cleanup ()
{
+ #ifndef AMIGA
if (0 < diffpid)
kill (diffpid, SIGPIPE);
if (tmpmade)
unlink (tmpname);
+ #else /* AMIGA */
+ if (tmpmade)
+ {
+ remove (tmpname);
+ tmpmade = 0;
+ }
+ #endif /* !AMIGA */
}
static void
***************
*** 230,235 ****
--- 295,301 ----
}
#endif
+ #ifndef AMIGA
#ifndef HAVE_WAITPID
/* Emulate waitpid well enough for sdiff, which has at most two children. */
static pid_t
***************
*** 259,264 ****
--- 325,331 ----
return pid;
}
#endif
+ #endif /* !AMIGA */
static char const *
expand_name (name, isdir, other_name)
***************
*** 273,278 ****
--- 340,346 ----
else
{
/* Yield NAME/BASE, where BASE is OTHER_NAME's basename. */
+ #ifndef AMIGA
const char
*p = rindex (other_name, '/'),
*base = p ? p+1 : other_name;
***************
*** 282,287 ****
--- 350,381 ----
r[namelen] = '/';
bcopy (base, r + namelen + 1, baselen + 1);
return r;
+ #else /* AMIGA */
+ const char *p1, *p2, *base;
+ size_t namelen, baselen;
+ char *r;
+
+ p1 = rindex (other_name, '/');
+ p2 = rindex (other_name, ':');
+ if (p1 == NULL && p2 == NULL)
+ base = other_name;
+ else
+ base = max (p1 + 1 , p2 + 1);
+ namelen = strlen (name);
+ baselen = strlen (base);
+ r = xmalloc (namelen + baselen + 2);
+ bcopy (name, r, namelen);
+ if (name[namelen-1] != ':')
+ {
+ r[namelen] = '/';
+ bcopy (base, r + namelen + 1, baselen + 1);
+ }
+ else
+ {
+ bcopy (base, r + namelen, baselen + 1);
+ }
+ return r;
+ #endif /* AMIGA */
}
}
***************
*** 409,414 ****
--- 503,520 ----
char *editor = getenv ("EDITOR");
char *differ = getenv ("DIFF");
+ #ifdef AMIGA
+ if (DOSBase->dl_lib.lib_Version < 37) {
+ fputs ("Need Amiga OS 2.0 (V.37) to execute.\n", stderr);
+ exit (20);
+ }
+ /* Install break and exit traps */
+ if (atexit (&amiga_exit))
+ fatal ("couldn't set exit trap");
+ if (onbreak (&amiga_break))
+ fatal ("couldn't set break trap");
+ #endif /* AMIGA */
+
prog = argv[0];
if (editor)
edbin = editor;
***************
*** 496,508 ****
--- 602,620 ----
if (! out_file)
/* easy case: diff does everything for us */
+ #ifndef AMIGA
execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1]);
+ #else /* AMIGA */
+ execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1], FALSE, NULL);
+ #endif /* !AMIGA */
else
{
FILE *left, *right, *out, *diffout;
int diff_fds[2];
int interact_ok;
+ #ifndef AMIGA
pid_t pid;
+ #endif
struct line_filter lfilt;
struct line_filter rfilt;
struct line_filter diff_filt;
***************
*** 517,522 ****
--- 629,636 ----
right = ck_fopen (expand_name (argv[optind + 1], rightdir, argv[optind]), "r");
out = ck_fopen (out_file, "w");
+ #ifndef AMIGA
+
if (pipe (diff_fds))
perror_fatal ("pipe");
***************
*** 545,562 ****
--- 659,709 ----
close (diff_fds[1]);
diffout = ck_fdopen (diff_fds[0], "r");
+ #else /* AMIGA */
+
+ {
+ BPTR StdOutDiff;
+ char pipe_name[20];
+
+ construct_pipe_name (pipe_name);
+
+ StdOutDiff = Open (pipe_name, MODE_NEWFILE);
+ if (!StdOutDiff)
+ perror_fatal ("pipe");
+
+ diff_fds[0] = open (pipe_name, O_RDONLY);
+ if (diff_fds[0] == -1)
+ perror_fatal ("pipe");
+
+ execdiff (0, "--sdiff-merge-assist", argv[optind], argv[optind + 1], TRUE, StdOutDiff);
+
+ }
+
+ diffout = ck_fdopen (diff_fds[0], "r");
+ diff_file = diffout;
+
+ #endif /* !AMIGA */
+
lf_init (&diff_filt, diffout);
lf_init (&lfilt, left);
lf_init (&rfilt, right);
interact_ok = interact (&diff_filt, &lfilt, &rfilt, out);
+ #ifndef AMIGA
ck_fclose (diffout);
+ #else /* AMIGA */
+ /* If the user signaled quit, let the exit code clean up the
+ pipe and close the file */
+ if (!user_quit)
+ ck_fclose (diffout);
+ #endif /* !AMIGA */
ck_fclose (left);
ck_fclose (right);
ck_fclose (out);
{
+ #ifndef AMIGA
int wstatus;
if (waitpid (pid, &wstatus, 0) < 0)
***************
*** 576,581 ****
--- 723,742 ----
fatal ("Subsidiary diff failed");
exit (WEXITSTATUS (wstatus));
+ #else /* AMIGA */
+ if (tmpmade)
+ {
+ remove (tmpname);
+ tmpmade = 0;
+ }
+
+ if (! interact_ok)
+ exit (2);
+
+ diff_file = NULL;
+
+ exit (0);
+ #endif /* !AMIGA */
}
}
return 0; /* Fool -Wall . . . */
***************
*** 604,609 ****
--- 765,772 ----
diffargv[diffargs++] = a;
}
+ #ifndef AMIGA
+
static void
execdiff (differences_only, option, file1, file2)
int differences_only;
***************
*** 623,631 ****
--- 786,870 ----
_exit (2);
}
+ #else /* AMIGA */
+
+ static void
+ execdiff (differences_only, option, file1, file2, asynch, handle)
+ int differences_only;
+ char *option, *file1, *file2;
+ long asynch;
+ BPTR handle;
+ {
+ struct TagItem STags[5];
+
+ if (differences_only)
+ diffarg ("--suppress-common-lines");
+ diffarg (option);
+ diffarg ("--");
+ diffarg (file1);
+ diffarg (file2);
+ diffarg (0);
+
+ construct_command_line (diffbin, diffargv, command_line);
+ if (asynch)
+ {
+ STags[0].ti_Tag = SYS_Input;
+ STags[0].ti_Data = NULL;
+ STags[1].ti_Tag = SYS_Output;
+ STags[1].ti_Data = handle;
+ STags[2].ti_Tag = SYS_Asynch;
+ STags[2].ti_Data = TRUE;
+ STags[3].ti_Tag = SYS_UserShell;
+ STags[3].ti_Data = TRUE;
+ STags[4].ti_Tag = TAG_DONE;
+ if (System (command_line, STags) != 0)
+ perror_fatal ("diff not found");
+ }
+ else
+ {
+ STags[0].ti_Tag = SYS_Asynch;
+ STags[0].ti_Data = FALSE;
+ STags[1].ti_Tag = SYS_UserShell;
+ STags[1].ti_Data = TRUE;
+ STags[2].ti_Tag = TAG_DONE;
+ if (System (command_line, STags) != 0)
+ perror_fatal ("diff not found");
+ exit (0);
+ }
+ }
+
+ static void
+ construct_command_line (binname, argvec, com_line)
+ char *binname, **argvec, *com_line;
+ {
+ int i;
+ strcpy (com_line, binname);
+ for (i = 1; argvec[i]; i++)
+ {
+ /* Enclose arguments in quotes */
+ strcat (com_line, " \"");
+ strcat (com_line, argvec[i]);
+ strcat (com_line, "\"");
+ }
+ }
+
+ static void
+ construct_pipe_name (pipe_name)
+ char *pipe_name;
+ {
+ static long invocations = 0;
+ struct Task *Task;
+
+ Task = FindTask (NULL);
+ sprintf (pipe_name, "PIPE:%08lX_%ld", Task, invocations);
+ }
+
+ #endif /* !AMIGA */
+
+ #ifndef AMIGA
/* Signal handling */
static int volatile ignore_signals;
***************
*** 670,675 ****
--- 909,915 ----
if (signal (*p, SIG_IGN) != SIG_IGN && signal (*p, catchsig) != SIG_IGN)
fatal ("signal error");
}
+ #endif /* !AMIGA */
***************
*** 796,802 ****
--- 1036,1046 ----
suppress_common_flag = 0;
break;
case 'q':
+ #ifdef AMIGA
+ user_quit = 1;
+ #endif
return 0;
+ #ifndef AMIGA
case 'e':
if (! tmpname && ! (tmpname = private_tempnam (0, "sdiff", 1, 0)))
perror_fatal ("temporary file name");
***************
*** 869,874 ****
--- 1113,1172 ----
}
return 1;
}
+ #else /* AMIGA */
+ case 'e':
+ if (! tmpname && ! (tmpname = tmpnam (NULL)))
+ perror_fatal ("temporary file name");
+
+ tmpmade = 1;
+
+ {
+ FILE *tmp;
+
+ tmp = ck_fopen (tmpname, "w");
+
+ if (cmd1 == 'l' || cmd1 == 'b')
+ lf_copy (left, lenl, tmp);
+ else
+ lf_skip (left, lenl);
+
+ if (cmd1 == 'r' || cmd1 == 'b')
+ lf_copy (right, lenr, tmp);
+ else
+ lf_skip (right, lenr);
+
+ ck_fclose (tmp);
+
+ {
+ struct TagItem STags[3];
+
+ sprintf (command_line, "%s \"%s\"", edbin, tmpname);
+ STags[0].ti_Tag = SYS_Asynch;
+ STags[0].ti_Data = FALSE;
+ STags[1].ti_Tag = SYS_UserShell;
+ STags[1].ti_Data = TRUE;
+ STags[2].ti_Tag = TAG_DONE;
+ if (System (command_line, STags) != 0)
+ perror_fatal ("Subsidiary editor failed");
+ }
+
+
+ {
+ static char *buf;
+ size_t size;
+
+ tmp = ck_fopen (tmpname, "r");
+
+ buf = xmalloc (SDIFF_BUFSIZE * sizeof (char));
+ while ((size = ck_fread (buf, SDIFF_BUFSIZE, tmp)) != 0)
+ ck_fwrite (buf, size, outfile);
+ free (buf);
+
+ ck_fclose (tmp);
+ }
+ return 1;
+ }
+ #endif /* !AMIGA */
default:
give_help ();
break;
***************
*** 959,964 ****
--- 1257,1264 ----
return stat (file, &buf) == 0;
}
+ #ifndef AMIGA
+
/* These are the characters used in temporary filenames. */
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
***************
*** 1065,1067 ****
--- 1365,1369 ----
*lenptr = len;
return buf;
}
+
+ #endif /* AMIGA */
diff -cr ram:diff-2.3/util.c dh1:diff-2.3/util.c
*** ram:diff-2.3/util.c Thu Nov 12 17:02:18 1992
--- dh1:diff-2.3/util.c Wed May 26 20:21:13 1993
***************
*** 19,24 ****
--- 19,35 ----
#include "diff.h"
+ #ifdef AMIGA
+ #include <signal.h>
+ #include <exec/types.h>
+ #include <dos/dostags.h>
+ #include <proto/dos.h>
+ #include <proto/exec.h>
+
+ extern struct DosLibrary *DOSBase;
+ static char tmpfilename[L_tmpnam];
+ #endif /* AMIGA */
+
/* Use when a system call returns non-zero status.
TEXT should normally be the file name. */
***************
*** 154,159 ****
--- 165,171 ----
strcat (name, current_name1);
if (paginate_flag)
+ #ifndef AMIGA
{
int pipes[2];
int desc;
***************
*** 187,192 ****
--- 199,224 ----
outfile = fdopen (pipes[1], "w");
}
}
+ #else /* AMIGA */
+ {
+ if (DOSBase->dl_lib.lib_Version < 37)
+ {
+ fputs ("Need Amiga OS 2.0 (V.37) to paginate. ", stderr);
+ fputs ("Using stdout instead.\n", stderr);
+ outfile = stdout;
+ }
+ else
+ {
+ /* Output the differences to a file and process the file with
+ * pr later on. This is a really bad hack (a kluge??? :-) ),
+ * but I couldn't find something better... */
+ tmpnam (tmpfilename);
+ outfile = fopen (tmpfilename, "w");
+ if (outfile == NULL)
+ pfatal_with_name ("pipe");
+ }
+ }
+ #endif
else
{
***************
*** 225,234 ****
--- 257,308 ----
finish_output ()
{
if (outfile != 0 && outfile != stdout)
+ #ifndef AMIGA
{
fclose (outfile);
wait (0);
}
+ #else /* AMIGA */
+ {
+ char *command_line;
+ struct TagItem STags[5];
+ BPTR StdInPr;
+
+ /* Close the temporary file and run pr with this file as input */
+ fclose (outfile);
+ command_line = (char *) xmalloc (strlen (current_name0)
+ + strlen (current_name1)
+ + strlen (switch_string) + 30);
+ strcpy (command_line, "pr -f -h \"");
+ strcat (command_line, "diff");
+ strcat (command_line, switch_string);
+ strcat (command_line, " ");
+ strcat (command_line, current_name0);
+ strcat (command_line, " ");
+ strcat (command_line, current_name1);
+ strcat (command_line, "\"");
+ StdInPr = Open (tmpfilename, MODE_OLDFILE);
+ if (StdInPr == NULL)
+ pfatal_with_name ("pipe");
+ STags[0].ti_Tag = SYS_Input;
+ STags[0].ti_Data = StdInPr;
+ STags[1].ti_Tag = SYS_Output;
+ STags[1].ti_Data = Output ();
+ STags[2].ti_Tag = SYS_Asynch;
+ STags[2].ti_Data = FALSE;
+ STags[3].ti_Tag = SYS_UserShell;
+ STags[3].ti_Data = TRUE;
+ STags[4].ti_Tag = TAG_DONE;
+ if (System (command_line, STags) != 0)
+ {
+ Close (StdInPr);
+ DeleteFile (tmpfilename);
+ pfatal_with_name ("pr");
+ }
+ Close (StdInPr);
+ DeleteFile (tmpfilename);
+ }
+ #endif /* !AMIGA */
outfile = 0;
}